C++11 - okreslanie typów

نویسنده

  • Piotr Beling
چکیده

template typename s td : : e n a b l e i f< ! s td : : i s t r i v i a l l y c o p y a s s i g n a b l e : : va lue > : : type mycopy( const T∗ source , T∗ dest , s td : : s i z e t count ) { for ( s td : : s i z e t i = 0 ; i < count ; ++i ) ∗ dest++ = ∗ source++; } Gdy pierwszym argumentem szablonu std :: enable if jest true, to zawiera on pole type określające typ drugiego argumentu (domyślnie void), w przeciwnym razie jest on pustą klasą. W ten sposób, dla dowolnego typu, tylko jedna z wersji mycopy będzie poprawnie zdefiniowana i użyta (istnienie drugiej nie spowoduje błędu kompilacji). Szablony klas których nazwy, typowo, zaczynają się od add , remove oraz make udostępniają, w polu type, zmodyfikowaną wersję typu będącego argumentem. Na przykład: typename remove const : : type // np . i n t gdy T j e s t cons t i n t Szablon std :: result of służy do ustalenia wartości zwracanej przez podany wskazany funktor: typename s td : : r e s u l t o f : : type // typ zwrócony pr ze z fun d la argumentu typu in t Ta zasada znana jest pod nazwą SFINAE (Substitution failure is not an error).

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Formalizacja naiwnej teorii typów

Językiem współczesnej matematyki jest teoria mnogości. Praktycznie wszystkie dowody matematyczne przeprowadza się na gruncie teorii zbiorów. Wszystkie książki i artykuły naukowe pisze się zakładając niejawnie aksjomaty ZF lub ZFC. Nawet nauczanie matematyki, od przedszkola po uniwersytet, prowadzi się na gruncie teorii mnogości. Jednak teoria mnogości została wprowadzona w zupełnie innym celu. ...

متن کامل

Endoscopic submucosal dissection with a Water-jet Hybrid-knife in a patient with metachronous gastric cancer – case report and review of literature

Endoskopowa dyssekcja podśluzówkowa (ESD) jest zaawansowaną metodą endoskopowego usuwania wczesnych zmian nowotworowych przełyku, żołądka czy odbytnicy. ESD polega na odwarstwieniu dyssekcji resekowanego obszaru od warstwy mięśniowej ściany przewodu pokarmowego, a następnie wycięciu za pomocą noża endoskopowego. Na rynku dostępnych jest kilkanaście typów noży endoskopowych. Jednym z nich jest n...

متن کامل

Study on transformer tank vibration characteristics in the field and its application

Vibration signal analysis method is one of effective methods to monitor the condition of transformer windings and core. In this paper, the multi-channels vibration measurement system is set up and the vibration signals on the oil-tank surface of running transformer in the field are measured. The influences of transformer type and sensor positions on the measured vibration signals are analyzed. ...

متن کامل

Determination of parameters for a half-band filter in a digital Hilbert transformer in a reactive power measurement system

This article presents a selection analysis of the parameters used for a half-band filter in a digital Hilbert transformer. The parameters were determined for the transformer’s use in measuring Budeanu reactive power. This solution allowed to check the operation of the filter by comparing the results obtained with the filter with the results of Budeanu reactive power obtained in the frequency do...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:
  • CoRR

دوره abs/1304.7600  شماره 

صفحات  -

تاریخ انتشار 2013